<?php

namespace app\model;

use think\Model;


//售后表

class Rmas extends Model
{
    // Define the table name
    protected $name = 'rmas';
    public $timestamps = false;

    //   'return'   => trans('rma.type_return'),
    //         'exchange' => trans('rma.type_exchange'),
    //         'repair'   => trans('rma.type_repair'),
    //         'reissue'  => trans('rma.type_reissue'),
    //         'refund'   => trans('rma.type_refund'),
    // 售后类型
    const TYPE_RETURN = 'return';
    const TYPE_EXCHANGE = 'exchange';
    const TYPE_REPAIR = 'repair';
    const TYPE_REISSUE = 'reissue';
    const TYPE_REFUND = 'refund';

    // 售后状态
    const STATUS_PENDING = 'pending';
    const STATUS_REJECTED = 'rejected';
    const STATUS_APPROVED = 'approved';
    const STATUS_SHIPPED = 'shipped';
    const STATUS_COMPLETED = 'completed';

    //  'pending'   => trans('rma.status_pending'),
    //         'rejected'  => trans('rma.status_rejected'),
    //         'approved'  => trans('rma.status_approved'),
    //         'shipped'   => trans('rma.status_shipped'),
    //         'completed' => trans('rma.status_completed'),

    // 售后状态文本描述
    public static function getRmaStatusText($status)
    {
        $statusMap = [
            Rmas::STATUS_PENDING => '待处理',
            Rmas::STATUS_REJECTED => '已拒绝',
            Rmas::STATUS_APPROVED => '已审批',
            Rmas::STATUS_SHIPPED => '已发货',
            Rmas::STATUS_COMPLETED => '已完成',
        ];

        return $statusMap[$status] ?? '未知状态';
    }

    // 售后类型文本描述
    public static function getRmaTypeText($type)
    {
        $typeMap = [
            Rmas::TYPE_RETURN => '退货',
            Rmas::TYPE_EXCHANGE => '换货',
            Rmas::TYPE_REPAIR => '维修',
            Rmas::TYPE_REISSUE => '补发',
            Rmas::TYPE_REFUND => '退款',
        ];

        return $typeMap[$type] ?? '未知类型';
    }
}
